import request from '@/utils/request'

export function getAllConsoleUserList() {
  return request({
    url: '/ConsoleUser/all',
    method: 'get'
  })
}

export function getConsoleUserById(id) {
  return request({
    url: '/ConsoleUser/',
    method: 'get',
    params: {
      userId: id
    }
  })
}

export function addUser(consoleUser) {
  return request({
    url: '/ConsoleUser/append',
    method: 'post',
    data: {
      username: consoleUser.username,
      password: consoleUser.password,
      userGroup: consoleUser.userGroup,
      realname: consoleUser.realname,
      orgId: consoleUser.orgId,
      userPhone: consoleUser.userPhone,
      state: 0
    }
  })
}

export function deleteUser(id) {
  return request({
    url: '/ConsoleUser/remove',
    method: 'get',
    params: {
      userId: id
    }
  })
}

export function updateUser(consoleUser) {
  return request({
    url: '/ConsoleUser/user',
    method: 'put',
    params: {
      userId: consoleUser.userId,
      username: consoleUser.username,
      password: consoleUser.password,
      userGroup: consoleUser.userGroup,
      realname: consoleUser.realname,
      orgId: consoleUser.orgId,
      userPhone: consoleUser.userPhone
    }
  })
}

export function conditionSearch(search) {
  return request({
    url: '/ConsoleUser/confident/search',
    method: 'post',
    data: {
      orgId: search.orgId,
      userGroup: search.userGroup,
      username: search.username
    }
  })
}

export function mohuSearch(str) {
  return request({
    url: '/ConsoleUser/mohu/search',
    method: 'post',
    data: {
      str: str
    }
  })
}

export function getUserByGroup(userGroup) {
  return request({
    url: '/ConsoleUser/userGroup',
    method: 'get',
    params: {
      userGroup: userGroup
    }
  })
}

export function getUserByGroup1(userGroup) {
  return request({
    url: '/ConsoleUser/userGroup1',
    method: 'get',
    params: {
      userGroup: userGroup
    }
  })
}
